
import service from "@/utils/https";
import type { Group, CollectTaskSelectParams, CollectTask, GroupList } from '../model/group';
import type { Result, ResultList } from "@/service/port";

/**
 * 获取任务组列表API
 */

export function GetGroupListApi() : Promise<Result<ResultList<GroupList>>>{
    return service({
        method: "GET",
        url: "/collectDataGroup"
    });
}


/**
 * 新增任务组API
 */
export const AddGroupApi = (data: Group) => {
    return service({
        method: "POST",
        url: "/collectDataGroup",
        data
    });
};

/**
 * 修改任务组API
 */
export const UpdateGroupApi = (data: Group) => {
    return service({
        method: "PUT",
        url: "/collectDataGroup",
        data
    });
};


/**
 * 删除任务组API
 */
export const DeleteGroupApi = (id: number) => {
    return service({
        method: "DELETE",
        url: `/collectDataGroup/${id}`
    });
};


/**
 * 获取任务采集器列表API
 */
export const GetDataCollectTaskApi = (data: CollectTaskSelectParams) => {
    return service({
        method: "POST",
        url: "/dataCollectTask/list",
        data
    });
};


/**
 * 新增任务采集器API
 */
export const AddDataCollectTaskApi  = (data: CollectTask) => {
    return service({
        method: "POST",
        url: "/dataCollectTask",
        data
    });
};

/**
 * 删除任务采集器API
 */
export const DeleteDataCollectTaskApi = (id: number) => {
    return service({
        method: "DELETE",
        url: `/dataCollectTask/${id}`
    });
};

/**
 * 修改任务采集器API
 */
export const UpdateDataCollectTaskApi = (data: CollectTask) => {
    return service({
        method: "PUT",
        url: "/dataCollectTask",
        data
    });
};




export interface CollectTaskUpdateStatus {
    id: number | undefined,
    status: boolean | undefined
}


/**
 * 打开|关闭任务采集器API
 */
export const OpenOrCloseDataCollectTaskApi = (data: CollectTaskUpdateStatus) => {
    return service({
        method: "POST",
        url: "/dataCollectTask/start",
        data
    })
}


/**
 * id获取任务采集器
 * @param id 采集器id
 * @returns 
 */
export const IdGetDataCollectApi = (id: number) => {
    return service({
        method: "GET",
        url: `/dataCollectTask/${id}`
    });
};

